/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.tramite.bc;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.cip.esymons.general.be.Solicitante;
import org.cip.esymons.tramite.be.Plantilla;
import org.cip.esymons.tramite.be.TipoDocumento;

/**
 *
 * @author FreddyHIQ
 */
public class PlantillaDelegate {

    private PlantillaFacadeLocal local;
    
    public PlantillaDelegate() {
        local=lookupPlantillaFacade();
    }

    public void create(Plantilla plant){
        local.create(plant);
    }

    public Plantilla find(Long id){
        return local.find(id);
    }

    public List<Plantilla> listarXDocumento(TipoDocumento doc){
        return local.listarPublicoXDocumento(doc);
    }

    public List<Plantilla> listarXSolicitante(Solicitante sol, TipoDocumento doc){
        return local.listarXSolicitante(sol, doc);
    }

    private PlantillaFacadeLocal lookupPlantillaFacade() {
        try {
            Context c = new InitialContext();
            return (PlantillaFacadeLocal) c.lookup("java:comp/env/PlantillaFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }    
}